var form = layui.form,
	layer = layui.layer;

$("#saveQuartz").click(function(){
	var formData = form.val('quartz-form');
	
	var oldJobGroup = $('#oldJobGroup').val();
	var oldJobName = $('#oldJobName').val();
	
	var jobName = formData.jobName;
	var jobGroup = formData.jobGroup;
	var description = formData.description;
	var jobClassName = formData.jobClassName;
	var jobMethodName = formData.jobMethodName;
	var cronExpression = formData.cronExpression;
	
	layer.load(2);
	
	$.ajax({
		type : 'post'
		,dataType : 'json'
		,url : access_url+'/quartz/manager/addjob'
		,data : {
			oldJobGroup : oldJobGroup
			,oldJobName : oldJobName
			,jobName : jobName
			,jobGroup : jobGroup
			,description : description
			,jobClassName : jobClassName
			,jobMethodName : jobMethodName
			,cronExpression : cronExpression
		}
		,success : function(data){
			layer.closeAll('loading');
			if(data.code != 200){
				layer.msg(data.msg, {icon: 5});
				return;
			}
			parent.layer.alert(data.msg,{icon:6});
			parent.loadTable();
			parent.layer.closeAll('iframe');
		}
	})
})

/**
 * 旧的定时任务属性回显
 * @returns
 */
function transmitParam(oldJobProperties){
	var jobName = oldJobProperties.jobName;
	var jobGroup = oldJobProperties.jobGroup;
	var description = oldJobProperties.description;
	var jobClassName = oldJobProperties.jobClassName;
	var jobMethodName = oldJobProperties.jobMethodName;
	var cronExpression = oldJobProperties.cronExpression;
	
	$('#oldJobGroup').val(jobGroup);
	$('#oldJobName').val(jobName);
	
	form.val('quartz-form',{
		'jobName':jobName
		,'jobGroup':jobGroup
		,'description':description
		,'jobClassName':jobClassName
		,'jobMethodName':jobMethodName
		,'cronExpression':cronExpression
	})
}